﻿using System;
using System.Data;
using System.Collections.Generic;
using NetDiskPRJ.Common;
using NetDiskPRJ.Model;
namespace NetDiskPRJ.BLL
{
	/// <summary>
	/// 用户组权限表
	/// </summary>
	public partial class PrvGrpMenu
	{
		
		public PrvGrpMenu()
		{}
        /// <summary>
        /// 根据用户组ID获取菜单列表
        /// <creator>wangl</creator>
        /// <date>2013-02-17</date>
        /// </summary>
        /// <returns></returns>
        public List<Model.PrvGrpMenu> GetMenuListByGrpid(string groupNo)
        {
            NetDiskPRJ.DAL.PrvGrpMenu prvGrpMenuDAL= new NetDiskPRJ.DAL.PrvGrpMenu();
            DataSet ds= prvGrpMenuDAL.GetMenuListByGrpid(groupNo);
            return DataTableToList(ds.Tables[0]);
        }

        /// <summary>
        /// 获得数据列表
        /// <creator>wangl</creator>
        /// <date>2013-02-17</date>
        /// </summary>
        private List<NetDiskPRJ.Model.PrvGrpMenu> DataTableToList(DataTable dt)
        {
            NetDiskPRJ.DAL.PrvGrpMenu prvGrpMenuDAL = new NetDiskPRJ.DAL.PrvGrpMenu();
            List<NetDiskPRJ.Model.PrvGrpMenu> modelList = new List<NetDiskPRJ.Model.PrvGrpMenu>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                NetDiskPRJ.Model.PrvGrpMenu model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = prvGrpMenuDAL.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }
        /// <summary>
        /// 获取所有权限菜单列表
        /// <creator>wangl</creator>
        /// <date>2013-02-18</date>
        /// </summary>
        /// <returns></returns>
        public List<Model.PrvGrpMenu> GetAllMenuList()
        {
            NetDiskPRJ.DAL.PrvGrpMenu prvGrpMenuDAL = new NetDiskPRJ.DAL.PrvGrpMenu();
            DataSet ds = prvGrpMenuDAL.GetList("");
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 增加一条数据
        /// <creator>wangl</creator>
        /// <date>2013-02-18</date>
        /// </summary>
        public bool AddGrpMneu(Model.PrvGrpMenu model)
        {
            NetDiskPRJ.DAL.PrvGrpMenu prvGrpMenuDAL = new NetDiskPRJ.DAL.PrvGrpMenu();
            return prvGrpMenuDAL.Add(model);
        }
        /// <summary>
        /// 删除用户组菜单权限
        /// <creator>wangl</creator>
        /// <date>2013-02-18</date>
        /// </summary>
        /// <param name="grp_id"></param>
        /// <returns></returns>
        public bool DeleteGrpMenu(Model.PrvGrpMenu model)
        {
            NetDiskPRJ.DAL.PrvGrpMenu prvGrpMenuDAL = new NetDiskPRJ.DAL.PrvGrpMenu();
            return prvGrpMenuDAL.Delete(model.FMenuItemName, model.FGroupNo);
        }
	}
}

